<?php
include("db/connect.php");
$sqlselectproduct="select * from product";
$sqlselectproduct.=" where pro_id like '%".@$_POST["txtsearch"]."%' group by pro_id";
$queryselectproduct=mysql_query($sqlselectproduct);
  $countX=1;
?>
<table width="100%" height="132" border="1" class="display" id="tb_product">
<thead>
  <tr>
    <th width="13%">ชื่อสินค้า</th>
    <th width="15%">รายละเอียดสินค้า</th>
    <th width="12%">จัดการข้อมูลวัตถุดิบ</th>
    <th width="5%">แก้ไข</th>
    <th width="9%">ลบ</th>
    <th width="12%">คลังสินค้า</th>
    <th width="12%">เพิ่มการผลิต</th>
  </tr>
  </thead>
   <tbody style="color:black !important;">
  <?php 
  while($resultproduct=mysql_fetch_array($queryselectproduct)){
  ?>
  <tr valIn="<?php echo $countX?>">
    <td><?php echo $resultproduct["pro_name"]?></td>
    <td><a href='Javascript:cartPop("<?php echo $resultproduct["pro_id"]?>");' >คลิกเพื่อดูรายละเอียด</a></td> 
    <td><a href="#" onclick="strucMaterial(<?php echo $countX?>,<?php echo $resultproduct["pro_id"];?>);">จัดการข้อมูลวัตถุดิบ</a></td>
    <td><a href="Javascript:ajaxmanage(2,<?php echo $resultproduct["pro_id"];?>);">แก้ไข</a></td>
    <td><a href="Javascript:ajaxmanage(1,<?php echo $resultproduct["pro_id"];?>);" onclick="return window.confirm('ต้องการลบใช่ไหม')">ลบ</a></td>
     <td><a href="#" onclick="storeMaterial(<?php echo $countX?>,<?php echo $resultproduct["pro_id"];?>);">คลังสินค้า</a></td><?php // echo $resultmaterial["mat_id"];?>
     <td><a href="Javascript:menufication(<?php echo $resultproduct["pro_id"];?>);">เพิ่มการผลิต</a></td>
  </tr>
  </tr>
  <?php     $countX++;}?>
   </tbody>
</table>
<div id="stock2"></div><div id="struc"></div>
<script>
 $(function() {
		/* For zebra striping */
        $("table tr:nth-child(odd)").addClass("odd-row");
		/* For cell text alignment */
		$("table td:first-child, table th:first-child").addClass("first");
		/* For removing the last border */
		$("table td:last-child, table th:last-child").addClass("last");
});</script>
<span id="struc" style="display:block"></span>
<script>
function strucMaterial(rows,proID){
	$("tbody > tr[valIn!="+rows+"]").remove();
	$.ajax({
		url:"strucmaterial.php?pro_id="+proID,
		success: function(msg){
			$("#struc").html('');
			$("#stock2").html('');
			$("#manufication").html('');
				$("#struc").html(msg);
				$("#struc").css({
					"display":"block !important"
					});
				$("#struc").slideDown();
			}
		});

	}
</script>

<script>
function storeMaterial(rows,proID){
	$("tbody > tr[valIn!="+rows+"]").remove();
	$.ajax({
		url:"list_productstock1.php?pro_id="+proID,
		success: function(msg){
			$("#stock2").html('');
			$("#struc").html('');
			$("#manufication").html('');
				$("#stock2").html(msg);
				$("#stock2").slideDown();
			}
		});

	}
</script>
<!-- menufication หน้าการผลิต -->
<script>
  var popup2;
	  function menufication(id) {
        //popup = window.open("detail_popup.php?order="+id, "Popup", "width=700,height=600");
		popup2 = window.open("manufication.php?product="+id, "Popup", "width=700,height=600");
        popup2.focus();
		
    }
</script>

<script>
  var popup;
	  function cartPop(id) {
        //popup = window.open("detail_popup.php?order="+id, "Popup", "width=700,height=600");
		popup = window.open("detail_popup.php?product="+id, "Popup", "width=700,height=600");
        popup.focus();
		
    }
</script>

<script>
$(document).ready(function(){

  	var oTable = $('#tb_product').dataTable({
          "bJQueryUI": true,
          "sPaginationType": "full_numbers"
      });
});
	  
	
</script>